package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.ImGroupRule;
import com.sc.nft.entity.vo.AdminGroupRuleVO;
import com.sc.nft.mapper.ImGroupRuleMapper;
import com.sc.nft.sup.PageRequest;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ImGroupRuleDao extends ServiceImpl<ImGroupRuleMapper, ImGroupRule> {

    public List<ImGroupRule> getAll() {
        QueryWrapper<ImGroupRule> imGroupRuleQueryWrapper = new QueryWrapper<>();
        return baseMapper.selectList(imGroupRuleQueryWrapper);
    }

    /**
     * 获取数据是否有交集
     *
     * @param id
     * @param start
     * @param end
     * @return
     */
    public Integer intersectionExamine(Long id, Integer start, Integer end) {
        return baseMapper.intersectionExamine(id, start, end);
    }

    /**
     * 根据官方群数量获取对应的用户
     *
     * @param sum
     * @return
     */
    public ImGroupRule accordingOfficialGroupSumGetRule(Integer sum) {
        return baseMapper.accordingOfficialGroupSumGetRule(sum);
    }
    /**
     * 后台获取配置规则列表
     * @param pageRequest
     * @return
     */
    public Page<AdminGroupRuleVO> getList(PageRequest pageRequest) {
        return baseMapper.getList(pageRequest.toMp());
    }

}
